package com.example.administrator.androidhomework2;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.TextureView;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    EditText mEtHeight;//身高控件
    RadioGroup mRgSex;//性别控件
    Button mBtnCompute;
    TextView mTResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mEtHeight = findViewById(R.id.et_height);
        mBtnCompute = findViewById(R.id.btn_compute);
        mRgSex = findViewById(R.id.rg_sex);
        mTResult = findViewById(R.id.tv_result);

        mBtnCompute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String sHeight = mEtHeight.getText().toString();
                int height = Integer.parseInt(sHeight);
                int height2 = Integer.parseInt(mEtHeight.getText().toString());

                int id = mRgSex.getCheckedRadioButtonId();
                if (id == R.id.rb_male){
                    int standardWeight =(int)((height - 100)* 0.9);
                    //mTResult.setText("标准体重是："+standardWeight+"KG");
                    Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();


                }else if (id == R.id.rb_female);
                int standardWeight = (int)((height)*0.9-2.5);
                mTResult.setText("标准体重是："+standardWeight+"KG");
            }
        });
    }
}
